home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene Storm
/
Scene Storm - Volume 1.iso
/
coding
/
c
/
ctimer
/
ctimer.doc
next >
Wrap
Text File
|
1995-11-05
|
4KB
|
110 lines
C T i m e r
Introduction
Two distinct timers are included in this package:
CTimer1
for system 1.3 or 2
CTimer2
for system 2 only.
Either can be used to measure the execution of any section of code from a
single line to a complete programme.
The main use of CTimer will be to help fine-tune any program which you
would like to speed up, by showing where excess time is being used, or
showing where a little machine_coding could be most profitable.
CTimer itself is a module that when linked to a suitably annotated
programme measures the execution time of selected sections of the programme.
The two versions are used in the same way.
CTimer test
.
Each drawer has the files:
ctimer[x].o object file to be linked with the programme under test.
ctimer[x].s source for ctimer[x].o
test.c test file ready to be compiled & linked with ctimer.o.
test.o compiled version of test.c (Lattice)
test[x] executable test file.
test[x]_linker Blink command line.
To reproduce test[x], execute test[x]_linker (may need modification to
suit your setup). Note that CTimer1 uses the mathffp.library.
Function1 measures the
dead
time, which must be deducted from the reported
running time to get a true figure.
Function2 measures the time taken by a
Ctime/Cend
pair - which will add to
the total running time of the program.
Function3 shows one way of handling multiple exits - the report will not
differentiate between exit points.
Use
CTimer has three accessable functions,
Ctime, Cend, and Creport
Ctime(reference number)
is called at the start of the section of code to
be timed, a different reference for each section.
Cend(reference number)
is called at the end of the timed section.
Reference must match the starting reference.
Creport()
is called at the exit from the programme.
If there are a number of possible exits it must be called at each.
A section may be a complete module, a function, or even a single line;
the only restriction is that it must have one unique entry point for Ctime.
Sections may be nested, see example in test.c.
When the required sections have been annotated, compile and link with
ctimer[x].o.
Operation
Operation of the programme is simple. When a Ctime call is noted its
reference is recorded with the current system time. On receipt of a
Cend the current list of Ctime calls is scanned for a matching
reference, a new current time noted and the time difference stored.
Output
Output is to stdout (the programme under test must provide a stdout - the
test.c files show a simple way of providing one for WorkBench programs)
in the form
function1 visits 6 secs 1 msecs 44 micros 186
function2 visits 2 secs 0 msecs 0 micros 250
etc
visits
- the number of times that section of code was used.
time
- running total of the time spent within the section. For
function2 above the average time per visit would have been 125 micros. If
the current figure for dead time were 40 micros, actual running time would
be 85 micros.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
CTimer is Freeware. It may be copied and distributed freely and used
without charge for non_profit-making purposes. Authority for profit-making
use should be obtained from the author below.
No responsibility can be accepted for any loss resuling from its use.
Comments, suggestions, bug-reports all welcome.
Chas A. Wyndham,
1265 Canning Mills Road,
Roleystone,
WA 6111.
Australia